﻿using MDT.LifeSewagePlatform.Conmmon;
using MDT.LifeSewagePlatform.InterfaceService;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace MDT.LifeSewagePlatform.ServiceInstance.Controllers
{
    /// <summary>
    /// 
    /// </summary>
    [Route("api/type")]
    [ApiController]
    public class DetailController : BaseController
    {
        /// <summary>
        /// 
        /// </summary>
        #region prop and ctor
        [Autowired]
        private  IDetailService _detailService { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public DetailController() 
        {
        }
        #endregion

        #region method service
        /// <summary>
        /// 获取验证的
        /// </summary>
        /// <returns></returns>
        [HttpGet("/verify")]
        public async Task<IActionResult> GetVerify()
        {
            List<PieView> pies = new List<PieView>();
            var data = await _detailService.GetDetails(9);
            foreach (var item in data)
            {
                PieView pie = new PieView();
                pie.Name = item.RowName;
                pie.Value = item.ID;
                pies.Add(pie);
            }
            return Ok200(pies,"数据查询成功！");
        }
        /// <summary>
        /// 百分比
        /// </summary>
        /// <returns></returns>
        [HttpGet("/usermore")]
        public async Task<IActionResult> GetUserMore()
        {
            List<PieView> pies = new List<PieView>();
            var data = await _detailService.GetDetails(5);
            foreach (var item in data)
            {
                PieView pie = new PieView();
                pie.Name = item.RowName;
                pie.Value = item.ID;
                pies.Add(pie);
            }
            return Ok200(pies, "数据查询成功！");
        }
        /// <summary>
        /// 连续上涨次数
        /// </summary>
        /// <returns></returns>
        [HttpGet("/useronce")]
        public async Task<IActionResult> GetUserOnce()
        {
            List<PieView> pies = new List<PieView>();
            var data = await _detailService.GetDetails(6);
            foreach (var item in data)
            {
                PieView pie = new PieView();
                pie.Name = item.RowName;
                pie.Value = item.ID;
                pies.Add(pie);
            }
            return Ok200(pies, "数据查询成功！");
        }
        /// <summary>
        /// 地区类型
        /// </summary>
        /// <returns></returns>
        [HttpGet("/place")]
        public async Task<IActionResult> GetPlaceType()
        {
            List<PieView> pies = new List<PieView>();
            var data = await _detailService.GetDetails(10);
            foreach (var item in data)
            {
                PieView pie = new PieView();
                pie.Name = item.RowName;
                pie.Value = item.ID;
                pies.Add(pie);
            }
            return Ok200(pies, "数据查询成功！");
        }
        #endregion
    }
}
